package com.ruoyi.edit.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.edit.utils.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.edit.mapper.GrowthObservationMapper;
import com.ruoyi.edit.domain.GrowthObservation;
import com.ruoyi.edit.service.IGrowthObservationService;
import com.ruoyi.common.core.text.Convert;

/**
 * 成长观察Service业务层处理
 * 
 * @author qiufeng
 * @date 2022-04-21
 */
@Service
public class GrowthObservationServiceImpl implements IGrowthObservationService 
{
    @Autowired
    private GrowthObservationMapper growthObservationMapper;

    /**
     * 查询成长观察
     * 
     * @param id 成长观察主键
     * @return 成长观察
     */
    @Override
    public GrowthObservation selectGrowthObservationById(String id)
    {
        return growthObservationMapper.selectGrowthObservationById(id);
    }

    /**
     * 查询成长观察列表
     * 
     * @param growthObservation 成长观察
     * @return 成长观察
     */
    @Override
    public List<GrowthObservation> selectGrowthObservationList(GrowthObservation growthObservation)
    {
        return growthObservationMapper.selectGrowthObservationList(growthObservation);
    }

    /**
     * 新增成长观察
     * 
     * @param growthObservation 成长观察
     * @return 结果
     */
    @Override
    public int insertGrowthObservation(GrowthObservation growthObservation)
    {
        growthObservation.setId(UuidUtil.getUuid());
        growthObservation.setDeleted(0);
        growthObservation.setCreated(new Date());
        growthObservation.setCreateBy(ShiroUtils.getLoginName());
        growthObservation.setCreatedName(ShiroUtils.getName());
        return growthObservationMapper.insertGrowthObservation(growthObservation);
    }

    /**
     * 修改成长观察
     * 
     * @param growthObservation 成长观察
     * @return 结果
     */
    @Override
    public int updateGrowthObservation(GrowthObservation growthObservation)
    {
        growthObservation.setCreateBy(ShiroUtils.getLoginName());
        growthObservation.setCreatedName(ShiroUtils.getName());
        return growthObservationMapper.updateGrowthObservation(growthObservation);
    }

    /**
     * 批量删除成长观察
     * 
     * @param ids 需要删除的成长观察主键
     * @return 结果
     */
    @Override
    public int deleteGrowthObservationByIds(String ids)
    {
        return growthObservationMapper.deleteGrowthObservationByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除成长观察信息
     * 
     * @param id 成长观察主键
     * @return 结果
     */
    @Override
    public int deleteGrowthObservationById(String id)
    {
        return growthObservationMapper.deleteGrowthObservationById(id);
    }
}
